﻿
using HiSport.Application.TestManagement.Test2Service;
using HiSport.Core.Entity.HiSportWebEntity;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace HiSport.Application.TestManagement
{

    //[ApiDescriptionSettings("测试", Tag = "测试", SplitCamelCase = false)]
    [ApiDescriptionSettings("TestManagement", Tag = "TestManagement", SplitCamelCase = false)]
    public class TextAppService: IDynamicApiController
    {

        private readonly ITest2Service _tsetApp;
        public readonly ISqlSugarClient _dbContext;

        public TextAppService(ITest2Service tsetApp, ISqlSugarClient dbContext)
        {
            _tsetApp = tsetApp;
            _dbContext = dbContext;
        }

        public async Task<string> Test02(string str)
        {
            return   await _tsetApp.Test02(str);
        }

        public async Task<SqlSugarPagedList<Test>> Test03(BasePageInput input)
        {
            return await _tsetApp.Test03(input);
        }

        public async Task<bool> Test04()
        {
            return await _tsetApp.Test04();
        }

        /// <summary>
        /// CodeFirst
        /// </summary>
        /// <returns></returns>
        public Task<bool> CodeFirst(List<string> tableNames)
        {
            var types = Assembly.Load("HiSport.Core").GetTypes()
                .Where(x => x.GetCustomAttribute<SugarTable>() != null && x.Namespace.Contains("HiSport.Core.Entity.HiSportEntity")).ToArray();
            //注入
            _dbContext.CodeFirst.InitTables(types);

            return Task.FromResult(true);
        }



    }
}
